// JavaScript Document
function KiemTraDangNhap()
{
	var us = document.getElementById("txtUS");
	if(us.value == "")
	{
		alert("Tên đang nhập rỗng");
		return false;	
	}
	var ps = document.getElementById("txtPS");
	if(ps.value == "")
	{
		alert("Mật khẩu không được rỗng");
		return false;
	}
	
	return true;
}

function KiemTraDangKy()
{	
	var dem =0;
	reg1=/^[0-9A-Za-z]+[0-9A-Za-z_]*@[\w\d.]+.\w{2,4}$/;
	var loi = document.getElementById("loi");

	var us = document.getElementById("txtTenDangNhap");
	
	if(us.value == "")
	{
		var err=document.getElementById("errTenDangNhap");
		err.innerHTML='<span class="redstar">Tên đăng nhập đang rỗng</span>';
		dem++;	
	}else document.getElementById("errTenDangNhap").innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';
	
	var pw = document.getElementById("txtMatKhau");
	if(pw.value.length<6){
		var err=document.getElementById("errMatKhau");
		err.innerHTML='<span class="redstar">Mật khẩu phải >= 6 ký tự</span>';
		dem++;
	}else document.getElementById("errMatKhau").innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';

	var rpw=document.getElementById("txtNhapLaiMatKhau");
	if(rpw.value != pw.value && rpw.value !="")
	{
		var err=document.getElementById("errNhapLaiMatKhau");
		err.innerHTML='<span class="redstar">Mật khẩu chưa trùng khớp</span>';
		dem++;	
	}
	if(rpw.value != ""&& rpw.value==pw.value) document.getElementById("errNhapLaiMatKhau").innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';
	else dem++;
	
	var email = document.getElementById("txtEmail");
	if(reg1.test(email.value)==false)
	{
		var err=document.getElementById("errEmail");
		err.innerHTML='<span class="redstar">Email chưa hợp lệ</span>';
		dem++;	
	}else document.getElementById("errEmail").innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';
	
	var reEmail = document.getElementById("txtNhapLaiEmail");
	if(reg1.test(reEmail.value)==false || reEmail.value=="")
	{
		var err=document.getElementById("errNhapLaiEmail");
		err.innerHTML='<span class="redstar">Chưa hợp lệ</span>';
		dem++;
	}
	if(reg1.test(reEmail.value)==true && reEmail.value == email.value && reEmail.value!="")
	{
		var err=document.getElementById("errNhapLaiEmail");
		err.innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';
	}
	var hoten=document.getElementById("txtHoTen");
	if(hoten.value == "")
	{
		var err=document.getElementById("errHoTen");
		err.innerHTML='<span class="redstar">Tên đại diện đang rỗng </span>';
		dem++;	
	}else document.getElementById("errHoTen").innerHTML='<span class="redstar"><img src="lib/image/check.jpg" /></span>';
	if(dem>0)
		return false;
	else
		return true;
	
}
function ChuyenTrangDangKy()
{
	window.location = "index.php?act=5";
}

function ChuyenTrangDangXuat()
{
	window.location = "inc/xlDangXuat.php";
}
function ChuyenTrangDangXuatQuanLy()
{
	window.location = "../inc/xlDangXuat.php";
}
function DangKyClick1()
{
	
	//document.write("<?php include("inc/incDangKy.php");?>)");
}

function loadHuyen(tinh)
{
	if (tinh=="")
	{
		document.getElementById("Huyen").innerHTML="<b>Vui lòng chọn tỉnh.</b>";
		return;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	 	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
		document.getElementById("Huyen").innerHTML=xmlhttp.responseText;
	}
	xmlhttp.open("GET","inc/incLoadHuyen.php?q="+tinh,true);
	xmlhttp.send();
}
